<template>
	<div class="link">
		<div class="link-content">
		</div>		
	</div>
</template>
<script>
	import { MessageBox } from 'mint-ui'
	import axios from 'axios'
	import Http from '../http.js'
	export default{
		data(){
			return{
				key: ''
			}
		},
		mounted(){
			var url = window.location.href;
			var key = url.substring(url.indexOf("=") + 1, url.length);
			this.key = key;
			var params = new URLSearchParams;
			params.append("key", this.key)
			axios.post(Http.WXWEBLOGIN, params).then(res => {
				var ret = res.data;
				var userinfo = ret['data']['userinfo'];
				var params = new URLSearchParams;
				window.localStorage.setItem("userinfo", JSON.stringify(userinfo));
				params.append("userinfo",  JSON.stringify(userinfo))
				axios.post(Http.WXLOGIN, params).then( res => {
					var redt = res.data;						
					if(redt.code == 1 && redt.msg == '登录成功'){
						window.localStorage.setItem("token", redt['data']['userinfo']['token']);
						this.$router.push("/")
					}else{
						this.$router.push({
							path: "/bind/phone"
						})
					}
				})
			})
		},
		methods: {
			submit: function(){

			}
		}
	}
</script>
<style lang="scss" scoped>
	.link{
		display: flex;
		align-items: center;
		position: fixed;
		width: 100%;
		height: 100%;
		background: rgb(256,256,256);
		font-size: 0.28rem;
		.link-content{
			width: 70%;
			margin-left: 15%;
			background: #fff;
			border-radius: 0.2rem;
			.title{
				padding: 1rem 0;
			}
			.btn{
				display: flex;
				height: 0.88rem;
				line-height: 0.88rem;
				p{
					flex: 0 0 50%;
					height: 0.88rem;
					text-align: center;
					&.submit{
						color: #3b6d24;
						font-weight: 700;
					}
				}
			}
		}
	}
</style>